package com.ys.nms.module.business.dal.mysql.storage;

import java.util.*;

import com.ys.nms.framework.common.pojo.PageResult;
import com.ys.nms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ys.nms.framework.mybatis.core.mapper.BaseMapperX;
import com.ys.nms.module.business.dal.dataobject.storage.StorageDO;
import org.apache.ibatis.annotations.Mapper;
import com.ys.nms.module.business.controller.admin.storage.vo.*;

/**
 * 存储表 Mapper
 *
 * @author zzy
 */
@Mapper
public interface StorageMapper extends BaseMapperX<StorageDO> {

    default PageResult<StorageDO> selectPage(StoragePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StorageDO>()
                .eqIfPresent(StorageDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(StorageDO::getStorageMib, reqVO.getStorageMib())
                .eqIfPresent(StorageDO::getStorageIndex, reqVO.getStorageIndex())
                .eqIfPresent(StorageDO::getStorageType, reqVO.getStorageType())
                .eqIfPresent(StorageDO::getStorageDescr, reqVO.getStorageDescr())
                .eqIfPresent(StorageDO::getStorageSize, reqVO.getStorageSize())
                .eqIfPresent(StorageDO::getStorageUnits, reqVO.getStorageUnits())
                .eqIfPresent(StorageDO::getStorageUsed, reqVO.getStorageUsed())
                .eqIfPresent(StorageDO::getStorageFree, reqVO.getStorageFree())
                .eqIfPresent(StorageDO::getStoragePerc, reqVO.getStoragePerc())
                .eqIfPresent(StorageDO::getStoragePercWarn, reqVO.getStoragePercWarn())
                .eqIfPresent(StorageDO::getStorageDeleted, reqVO.getStorageDeleted())
                .orderByDesc(StorageDO::getStorageType));
    }

}